<template>
	<view class="u-p-y-30 u-p-l-20">
		<view class="" style="padding-bottom: 50px;">
			<view class="flex align-center justify-between u-m-b-20 u-m-r-20 u-p-l-20 box-shadow" v-for="(item,index) in list" :key="index">
				<u-checkbox-group class="" style="width: 100%;" wrap>
					<u-checkbox class="" :name="item.id" v-model="item.checked" @change="checkboxChange" >
						<view class="flex align-center justify-between bg-white u-m-l-10 rounded-10" style="height: 170rpx;">
							<view class="flex align-center justify-center" style="height: 100%; width: 150rpx;">
								<view class="u-p-y-30 text-center" style="width: 100%;border-right: 1rpx solid red;">
									<text class="coupon-text-colo" style="font-size: 40rpx;">{{item.preferential_type==1?"￥":"折"}}</text>
									<text class=" coupon-text-colo font-weight-bold" style="font-size: 40rpx;">{{item.preferential_type==1?item.money*1:item.discount*1}}</text>
								</view>
							</view>
							<view class="flex flex-column align-center">
								<text class="u-font-30 font-weight-bold coupon-text-colo">满{{item.fullmoney}}元使用</text>
								<text class="coupon-text-colo">{{item.content}}</text>
								<!-- <text class="u-font-20 coupon-text-colo">使用时间：{{item.begintime}}到{{item.endtime}}</text> -->
							</view>
							<view class="flex flex-column align-center justify-center coupon-bg-colo rounded-10" style="width: 100rpx;height: 100%;">
								<view class="flex flex-column" >
									<text class="u-font-28 font-weight-bold text-white">立即</text>
									<text class="u-font-28 font-weight-bold text-white">使用</text>
								</view>
							</view>
						</view>
					</u-checkbox>
				</u-checkbox-group>
			</view>
		</view>
		
		<view class="position-fixed bottom-0 left-0 right-0 safe-bottom">
			<view class="text-center border-top u-p-y-20 bg-white" >
				<dy-button width="500rpx" backgroundColor="var(--mainColor)" size="medium" @click="sure">确认</dy-button>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: 'goods-order-coupupPopup',
		data() {
			return {
				currentObj:{},
				list: []
			}
		},
		methods:{
			sure() {
				let money = ''
				if(this.currentObj.preferential_type ==1) {
					money = this.currentObj.money || ''
				}else if(this.currentObj.preferential_type ==2) {
					money = this.currentObj.discount*1 +'折'
				}
				let params = {
					merch_id: this.currentObj.merch_id || '',
					id: this.currentObj.id || '',
					money: money
				}
				console.log(params)
				this.$emit('click', params)
			},
			checkboxChange(e) {
				console.log(22222, e);
				for (let v of this.list) {
					v.checked = false
				}
				for (let v of this.list) {
					if(e.value && v.id == e.name) {
						v.checked = true
						this.currentObj = v
						break
					}else{
						this.currentObj = {}
					}
				}
				// console.log(6666, this.currentObj);
			},
		}
	}
</script>

<style lang="scss" scoped>
	.coupon-text-colo {
		color: #E0302D;
	}
	.coupon-bg-colo {
		background-color: #E0302D;
	}
	.coupon-border-colo {
		border-color: #E0302D;
	}
	::v-deep .u-checkbox__label {
		flex: 1;
	}
</style>
